package tech.aistar.day06.homework02;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * 本类用来演示: 员工父类
 *
 * @author: success
 * @date: 2021/3/16 9:05 上午
 */
public class Employee {
    private String name;

    //生日
    private Date birthday;

    public Employee(){

    }

    public Employee(String name, Date birthday) {
        this.name = name;
        this.birthday = birthday;
    }

    /**
     * 如果过生日,奖励100
     * @param month
     * @return
     */
    public double getSalary(int month){
        //1. 构建一个日历对象
        Calendar cal = new GregorianCalendar();
        //2. 将Date类型转换成Calendar类型
        cal.setTime(birthday);
        //3. 为了在程序中避免使用Date中过时的方法
        double salary = 0.0d;

        if(cal.get(Calendar.MONTH)+1 == month)
            salary = 100.0d;

        return salary;
    }
}
